package com.lzb.yabbs.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.lzb.yabbs.AppConfig;
import com.lzb.yabbs.app.BaseListFragment;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by zaibinng on 2015/9/6.
 */
public class TabAdapter extends FragmentPagerAdapter {

    private final String TAG=getClass().getSimpleName();

    private List<Fragment> fragments=new ArrayList<>();

    private String[] titles={"发现","最火","热门","关注"};

    public TabAdapter(FragmentManager fm) {
        super(fm);
        fragments.add(BaseListFragment.newInstance(AppConfig.URL_GET_LATEST,titles[0]));
        fragments.add(BaseListFragment.newInstance("",titles[1]));
        fragments.add(BaseListFragment.newInstance("",titles[2]));
        fragments.add(BaseListFragment.newInstance("",titles[3]));
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return titles[position];
    }

    @Override
    public Fragment getItem(int position) {

        return fragments.get(position);
    }

    @Override
    public int getCount() {
        return fragments.size();
    }
}
